#pragma once
#include "OgreLogManager.h"
#include "util.h"


#define _MAX_LIS 3
class ScoreListener{
public:	virtual void scoreUpdated(int newScore)=0;
};
class ScoreMgr
{
public:
	static ScoreMgr* getInstance(){
		static ScoreMgr* instance = 0;
		if(!instance) {
			instance = new ScoreMgr();
		}
		return instance;
	}

	ScoreListener * _listeners[_MAX_LIS];int _nl;//number of listeners 
	void addScoreListener(ScoreListener *sl){
		ASSERT(_nl<_MAX_LIS-1);
		_listeners[_nl++]=sl; 
	}
	void removeScoreListener(ScoreListener *sl){
		int i=0;
		ASSERT(_nl>=0);
		for(;i<_nl;i++){
			if(_listeners[i]==sl){
				break;
			}
		}
		if(i!=_nl){ //found it 
			for(;i<_nl+1;i++){
				_listeners[i]=_listeners[i+1];	
			}
		}
		--_nl;
	}
	~ScoreMgr(void);
	int getScore() const;
private:
	void setScore(int val);
private:
	int _score;
	
private:
	ScoreMgr(void){}
};